﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.ServiceReference1;
using System.Data.Services.Client;

namespace WebApplication1
{
    public partial class MeciuriArbitrate : System.Web.UI.Page
    {
        private Uri serviceUri = new Uri("http://localhost:50000/FootballService.svc/");
        WebApplication1.ServiceReference1.FotbalEntities context;

        protected void Page_Load(object sender, EventArgs e)
        {
            context = new WebApplication1.ServiceReference1.FotbalEntities(serviceUri);
            if (!IsPostBack)
            {
                BindMeciuriArbitrate();

            }
        }

        private void BindMeciuriArbitrate()
        {
            DataServiceQuery<WebApplication1.ServiceReference1.Meciuri> meciuri =
            context.CreateQuery<WebApplication1.ServiceReference1.Meciuri>("/Meciuris");
            DataServiceQuery<WebApplication1.ServiceReference1.Echipe> echipe =
            context.CreateQuery<WebApplication1.ServiceReference1.Echipe>("/Echipes");

            var query = from m in meciuri
                        join e in echipe
                        on m.CodEchipaGazda equals e.CodEchipa
                        where m.CodArbitru == Decimal.Parse(Server.UrlDecode(Request.QueryString["CodArbitru"]))
                        select new {  m, e };

            ListView_MeciuriArb.DataSource = query;
            ListView_MeciuriArb.DataBind();
        }

    }
}